package com.zsrt.java.day20161229.lh.day.demo05;

import java.util.Scanner;

import org.junit.Test;

public class TankTest {

	@Test
	public void wucan() {
		Tank tk=new Tank();
		tk.setPrice("300$");
		tk.setRange(800);
		tk.setSpeed(90);
		
		
		System.out.println(tk);
		
	}
	@Test
	public void youcan() {
		Tank tk=new Tank("500$",120,800);
		System.out.println(tk);
	
	}
	
	@Test
	public void shoot() throws Exception {
		
		Tank tk = new Tank();
		tk.setPrice("300$");
		//射程
		tk.setRange(4000);
		tk.setSpeed(90);
		
		Scanner sc=new Scanner(System.in);
		System.out.println("输入发射导弹类型：1、飞无腿导弹。2、爱国者导弹");
		int s=sc.nextInt();
		System.out.println("输入攻打的地方：1、美国，距离4000。2、日本，距离3000");
		int s1=sc.nextInt();
		if(1==s){
			String name="飞无腿导弹";
			if(s1==1){
				int di=4000;
				shoot(name,di);
			}else{
				int di=3000;
				shoot(name,di);
			}
		}else if(2==s){
			String name="爱国者导弹";
			if(s1==1){
				int di=4000;
				shoot(name,di);
			}else{
				int di=3000;
				shoot(name,di);
			}
		}
		sc.close();
		
	}
	
	
	public static void shoot(String name, int distance){
		if("飞无腿导弹".equals(name) && distance<5000){
			System.out.println("成功击中,射程"+distance);
		}else if("爱国者导弹".equals(name) && distance<4000){
			System.out.println("成功击中,射程"+distance);
		}else{
			System.out.println("没有打中");
		}
	}
	
	

}
